package cn.itcast.demo2;

import java.util.Objects;

public class Student {
    private int id;
    private String name;
    private int score;

    public Student(){}
    public Student(int id,String name,int score){
        this.id = id;
        this.name =name;
        this.score = score;
    }

    public int getId(){
        return id;
    }
    public void setId(int id){
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }


    //toString
    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", score=" + score +
                '}';
    }


//    public boolean equals(Object obj){
//        Student s2 = (Student) obj;
//        return this.id == s2.id;
//    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return id == student.id &&
                score == student.score &&
                Objects.equals(name, student.name);
    }

}
